<?php

	function currentDate()
	{
		return date("Y-m-d");
	}
	
	function dateToAppDate($oldDate)
	{
		$oldDateTimestamp = strtotime($oldDate);
		$newDate = date("dd.mm.YYYY", $oldDateTimestamp);
		return $newDate;
	}
	
	function appDateToDate($oldDate)
	{
		$oldDateTimestamp = strtotime($oldDate);
		$newDate = date("Y-m-d", $oldDateTimestamp);
		return $newDate;
	}
	
	function addMonthToDate($oldDate, $monthCount)
	{
		$addStr = $monthCount < 0 ? "-" : "+";
		$addStr .= $monthCount . " month";
		$newDate = date("Y-m-d", strtotime($addStr, strtotime($oldDate)));
		return $newDate;
	}
	
	function addDayToDate($oldDate, $dayCount)
	{
		$addStr = $dayCount < 0 ? "-" : "+";
		$addStr .= $dayCount . " day";
		$newDate = date("Y-m-d", strtotime($addStr, strtotime($oldDate)));
		return $newDate;
	}
	
	function addYearToDate($oldDate, $yearCount)
	{
		$addStr = $yearCount < 0 ? "-" : "+";
		$addStr .= $yearCount . " year";
		$newDate = date("Y-m-d", strtotime($addStr, strtotime($oldDate)));
		return $newDate;
	}
	
	function lastDayInMonth($oldDate)
	{
		$lastDay = date("Y-m-t",strtotime($oldDate));
		return $lastDay;
	}
?>
